<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        span {
            color: white;
            padding: 8px;
            margin: 5px;
            float: left;
        }

        .green {
            background-color: green;
        }

        .blue {
            background-color: blue;
        }
    </style>
</head>

<body>
    <span class="green">绿色1</span>
    <span class="blue">蓝色1</span>
    <span class="green">绿色2</span>
    <span class="blue">蓝色2</span>
    <script src="js/jquery-3.4.1.js" type="text/javascript" charset="UTF-8"></script>
    <script type="text/javascript">
        //删除元素
        //   $(".green").remove();
        //清空元素
        //   $(".blue").empty();
        //遍历元素
        //获取指定元素 并遍历
        $(".green").each(function (index, element) {
            console.log(index);
            console.log(element);
        });

    </script>
</body>

</html>